package com.cloud.quickcore.admin.entity;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * 角色表
 *
 * @author NiJo_H
 * @version 1.0
 * @date 2019/8/11 14:07
 */
@Entity
@Table(name = "sys_role")
@Data
public class SysRole {
    @Id
    @SequenceGenerator(name = "seq_role", sequenceName = "seq_roleseq_role", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_role")
    @Column(name = "id")
    private Long id;

    /**
     * 角色字符串
     */
    @Column(name = "role_code", length = 20)
    private String roleCode;
    /**
     * 角色名称
     */
    @Column(name = "name", length = 20)
    private String name;

    /**
     * 删除标志
     */
    @Column(name = "deleted")
    private Boolean deleted = false;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "create_at")
    private LocalDateTime createAt;

    /*更新时间*/
    @UpdateTimestamp
    @Column(name = "update_at")
    private LocalDateTime updateAt;

    @ManyToMany
    @JoinTable(name = "sys_role_permission", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = {@JoinColumn(name = "permission_id")})
    private Set<SysPermission> permissions;

}
